import Vue from 'vue'
import Router from 'vue-router'
import Main from '@/components/main.vue'
import LoginIndex from '@/components/login.vue'
import Register from '@/components/register.vue'
import GoodsTable from '@/components/goodsTable.vue'
import ApplWarehouse from '@/components/warehouse/applWarehouse.vue'
import ManageWarehouse from '@/components/warehouse/manageWarehouse.vue'
import WarehouseData from '@/components/analysedata/warehouseData.vue'
import GoodsCount from '@/components/analysedata/goodsCount.vue'


Vue.use(Router)
//获取原型对象上的push函数
const originalPush = Router.prototype.push
//修改原型对象中的push方法
Router.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}


export default new Router({
  mode:'history',
  routes: [
    {
      path: '/',
      name: 'LoginIndex',
      component: LoginIndex,
      meta:{
        index:0,
        name:"登录页面"
      }
    },
    {
      path: '/register',
      name: 'Register',
      component: Register,
      meta:{
        index:0,
        name:"注册页面"
      }
    },
    {
      path: '/main',
      name: 'Main',
      component: Main,
      meta:{
        index:1,
        name:"主页页面"
      },
      children:[
        {
          path: '/warehouse/applWarehouse',  // /功能模块/页面描述名称
          name: 'ApplWarehouse',
          component: ApplWarehouse,
          meta:{
            index:1-1,
            name:"保鲜仓申请"
          }
        },
        {
          path: '/warehouse/manageWarehouse',  // /功能模块/页面描述名称
          name: 'ManageWarehouse',
          component: ManageWarehouse,
          meta:{
            index:1-2,
            name:"管理保鲜仓"
          }
        },
        {
          path: '/goods/table',  // /功能模块/页面描述名称
          name: 'GoodsTable',
          component: GoodsTable,
          meta:{
            index:1-3,
            name:"台账管理"
          }
        },
        {
          path: '/analysedata/warehouseData',  // /功能模块/页面描述名称
          name: 'WarehouseData',
          component: WarehouseData,
          meta:{
            index:1-4,
            name:"仓库数据信息"
          }
        },
        {
          path: '/analysedata/goodsCount',  // /功能模块/页面描述名称
          name: 'GoodsCount',
          component: GoodsCount,
          meta:{
            index:1-5,
            name:"仓库数据信息"
          }
        },
      ],
    },
    
    

  ]
})
